{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "819823d1-6548-474a-ab07-0e621f11bb67",
   "metadata": {},
   "outputs": [],
   "source": [
    "var openDigger = require('../../../src/open_digger');"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0cb573bd-5476-46e4-95ce-ca7f883a5e81",
   "metadata": {},
   "source": [
    "# 蚂蚁集团项目开发者分析"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a36485ac-3ee5-490c-8abd-53113c064957",
   "metadata": {},
   "source": [
    "## 蚂蚁项目贡献者分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "98b8ef07-c749-4db5-92b5-f34e02f3a833",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start to get contributors of antgroup for every project\n",
      "┌─────────┬────────────────────────────────┬────────────────┬─────────────────────────────────────────────────┐\n",
      "│ (index) │              name              │ developerCount │                   developers                    │\n",
      "├─────────┼────────────────────────────────┼────────────────┼─────────────────────────────────────────────────┤\n",
      "│    0    │          'Ant Design'          │      458       │          'li-jia-nan,alazypig,day-xue'          │\n",
      "│    1    │             'cnpm'             │      177       │         'asdw741111,elrrrrrrr,ChenYFan'         │\n",
      "│    2    │             'AntV'             │      152       │      'noneAuth,DanielLeefu,lhb2631225005'       │\n",
      "│    3    │          'OceanBase'           │      146       │          'Hayak3,521xueweihan,ob-lzq'           │\n",
      "│    4    │       'React Component'        │      106       │           'bbb169,li-jia-nan,yoyo837'           │\n",
      "│    5    │          'SecretFlow'          │       95       │        'maths644311798,lyvansky,Angelii'        │\n",
      "│    6    │       'Kata Containers'        │       94       │           'Camelron,yaoyinnan,msanft'           │\n",
      "│    7    │         'EosphorosAI'          │       87       │        'wzc570738205,nightosong,Hui824'         │\n",
      "│    8    │         'Apache Seata'         │       86       │       'Code-Fight,SABERYJS,hmj776521114'        │\n",
      "│    9    │            'UmiJS'             │       80       │          'wangz-code,liuyib,likendev'           │\n",
      "│   10    │          'Sofastack'           │       71       │       'gaosaroma,huanglongchao,SABERYJS'        │\n",
      "│   11    │           'TuGraph'            │       53       │            'noneAuth,gtahoo,123Whq'             │\n",
      "│   12    │             'Fury'             │       52       │      'weijiang157152688,vesense,mandrean'       │\n",
      "│   13    │          'Dragonfly'           │       51       │         'gaius-qi,alohaHZ,daiyongxuan'          │\n",
      "│   14    │           'NG-ZORRO'           │       48       │      'yuhengzhouz,Zz-ZzzZ,gregorybleiker'       │\n",
      "│   15    │         'KusionStack'          │       47       │ 'ekjotsinghmakhija,panshuai-ps,virtually-stray' │\n",
      "│   16    │          'Asterinas'           │       46       │         'cchanging,dequeueing,Champii'          │\n",
      "│   17    │           'CodeFuse'           │       42       │      'bingxuchai,Geralt-Targaryen,FunJim'       │\n",
      "│   18    │           'KCL Lang'           │       40       │          'jheyduk,shruti2522,XiaoK29'           │\n",
      "│   19    │           'OpenSumi'           │       36       │           'Aaaaash,weiwen111,Souls-R'           │\n",
      "│   20    │             'MOSN'             │       29       │     'hanxiantao,dependabot[bot],wjcgithub'      │\n",
      "│   21    │ 'Intelligent Machine Learning' │       29       │       'adamantboy,jlsong01,rockychan724'        │\n",
      "│   22    │            'EggJS'             │       29       │            'Wai-Dung,atian25,sullay'            │\n",
      "│   23    │           'Galacean'           │       25       │       'GuoLei1990,dependabot[bot],RGCHN'        │\n",
      "│   24    │           'OpenSPG'            │       25       │       'caszkgui,yixianlzz,xionghuaidong'        │\n",
      "│   25    │        'Apache HoraeDB'        │       21       │      'chunshao90,dependabot[bot],zealchen'      │\n",
      "│   26    │        'agentUniverse'         │       18       │          'EdwinInAu,Wyiying,istarwyh'           │\n",
      "│   27    │         'Traas Stack'          │       15       │          'masaimu,itonyli,mooneylert'           │\n",
      "│   28    │           'Tongsuo'            │       12       │           'wa5i,naghaabirami,szabgab'           │\n",
      "│   29    │          'Ant Chain'           │       11       │          'i-zhen,NeverRaR,liuys-dase'           │\n",
      "│   30    │          'Peter Cat'           │       9        │          'raojinlin,afc163,sedationh'           │\n",
      "│   31    │            'Occlum'            │       9        │        'lucassong-mh,wsjswy,volcano0dr'         │\n",
      "│   32    │             'VSAG'             │       6        │           'LHT129,wxyucs,jiacai2050'            │\n",
      "│   33    │           'CeresDB'            │       4        │         'zealchen,jiacai2050,discord9'          │\n",
      "│   34    │           'SQLFlow'            │       3        │       'workingloong,weiguoz,lucastheisen'       │\n",
      "│   35    │            'Macaca'            │       3        │          'echizen,yihuineng,tumor800'           │\n",
      "│   36    │         'HyperEnclave'         │       2        │               'Bonjourz,yilingxu'               │\n",
      "│   37    │       'Ant Mini Program'       │       2        │                'zaSang,bytemain'                │\n",
      "│   38    │            'DvaJS'             │       1        │                  'jasonzhuang'                  │\n",
      "│   39    │            'Couler'            │       1        │                  'ignite-abd'                   │\n",
      "└─────────┴────────────────────────────────┴────────────────┴─────────────────────────────────────────────────┘\n"
     ]
    }
   ],
   "source": [
    "var defaultOption = {\n",
    "    startYear: 2024, startMonth: 1, endYear: 2024, endMonth: 12,\n",
    "    groupTimeRange: 'year', precision: 2,\n",
    "    limit: -1, limitOption: 'all',\n",
    "    order: 'DESC',\n",
    "};\n",
    "var getProjectContributors = async () => {\n",
    "    console.log('Start to get contributors of antgroup for every project');\n",
    "    const contributorsData = await openDigger.metric.chaoss.contributors({\n",
    "        ...defaultOption,\n",
    "        labelUnion: [':companies/antgroup'],\n",
    "        groupBy: 'Project',\n",
    "    });\n",
    "    console.table(contributorsData.filter(row => row.name != 'Others').map(row => ({\n",
    "        name: row.name,\n",
    "        // 贡献者总数\n",
    "        developerCount: +row.count[0],\n",
    "        // 贡献者采样\n",
    "        developers: row.detail[0].slice(0, 3).join(','),\n",
    "    })).sort((a, b) => b.developerCount - a.developerCount));\n",
    "};\n",
    "getProjectContributors();"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59da590b-d240-4b88-9d77-bea12c2db80b",
   "metadata": {},
   "source": [
    "## 蚂蚁项目 OpenRank 贡献者分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fec41afc-f475-48d3-8054-bab2be999a14",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start to get contributors by OpenRank of antgroup for every project\n",
      "┌─────────┬────────────────────────────────┬────────────────┬─────────────────────────────────────────────────────────────────┐\n",
      "│ (index) │              name              │ developerCount │                           developers                            │\n",
      "├─────────┼────────────────────────────────┼────────────────┼─────────────────────────────────────────────────────────────────┤\n",
      "│    0    │          'Ant Design'          │      5065      │       'afc163(311.60),zombieJ(158.05),li-jia-nan(138.43)'       │\n",
      "│    1    │             'AntV'             │      1703      │      'Aarebecca(167.26),lijinke666(101.47),hustcc(75.92)'       │\n",
      "│    2    │            'UmiJS'             │      1085      │         'fz6m(51.85),sorrycc(47.19),PeachScript(39.26)'         │\n",
      "│    3    │         'EosphorosAI'          │      661       │        'Aries-ckt(67.32),fangyinc(57.95),csunny(51.99)'         │\n",
      "│    4    │       'React Component'        │      497       │        'afc163(72.05),zombieJ(68.91),li-jia-nan(29.35)'         │\n",
      "│    5    │          'SecretFlow'          │      459       │        'anakinxc(164.01),tongke6(34.73),wangzul(27.84)'         │\n",
      "│    6    │          'OceanBase'           │      437       │       'yhilmare(93.71),hnwyllmm(85.65),dengfuping(69.52)'       │\n",
      "│    7    │         'Apache Seata'         │      398       │     'funky-eyes(102.55),slievrly(89.69),xingfudeshi(21.67)'     │\n",
      "│    8    │           'NG-ZORRO'           │      339       │   'Laffery(40.24),HyperLife1119(31.55),ParsaArvanehPA(18.25)'   │\n",
      "│    9    │       'Kata Containers'        │      326       │      'fidencio(83.59),GabyCT(65.59),stevenhorsman(51.81)'       │\n",
      "│   10    │             'cnpm'             │      255       │      'fengmk2(69.66),elrrrrrrr(20.94),wangluyu-798(2.83)'       │\n",
      "│   11    │           'KCL Lang'           │      215       │           'Peefy(96.83),zong-zhe(62.53),He1pa(46.37)'           │\n",
      "│   12    │          'Sofastack'           │      196       │       'lvjing2(52.90),EvenLjj(24.58),HzjNeverStop(21.10)'       │\n",
      "│   13    │           'CodeFuse'           │      182       │ 'lightislost(37.76),Geralt-Targaryen(19.62),peng3307165(11.68)' │\n",
      "│   14    │             'Fury'             │      168       │   'chaokunyang(94.93),LiangliangSui(17.22),theweipeng(10.23)'   │\n",
      "│   15    │          'Dragonfly'           │      152       │        'gaius-qi(220.57),imeoer(34.34),Liam-Zhao(24.59)'        │\n",
      "│   16    │           'OpenSPG'            │      148       │        'andylau-55(33.09),fishjoy(19.94),baifuyu(16.05)'        │\n",
      "│   17    │           'TuGraph'            │      140       │      'ljcui(43.32),qishipengqsp(37.80),lipanpan03(26.92)'       │\n",
      "│   18    │            'EggJS'             │      138       │           'fengmk2(43.20),killagu(25.52),gxkl(5.03)'            │\n",
      "│   19    │ 'Intelligent Machine Learning' │      110       │     'workingloong(73.49),BalaBalaYi(50.02),samplise(15.72)'     │\n",
      "│   20    │           'OpenSumi'           │      106       │         'bytemain(132.51),Ricbet(68.46),erha19(44.05)'          │\n",
      "│   21    │          'Asterinas'           │      105       │   'tatetian(90.75),junyang-zh(42.07),StevenJiang1110(31.63)'    │\n",
      "│   22    │           'Tongsuo'            │       91       │       'InfoHunter(34.47),dongbeiouba(31.52),wa5i(18.58)'        │\n",
      "│   23    │         'KusionStack'          │       74       │       'liu-hm19(49.63),SparkYuan(49.56),elliotxx(48.35)'        │\n",
      "│   24    │            'Occlum'            │       71       │      'volcano0dr(22.64),qzheng527(21.53),jessehui(12.13)'       │\n",
      "│   25    │             'MOSN'             │       67       │    'spacewander(71.06),alpha-baby(11.54),15669072513(5.23)'     │\n",
      "│   26    │           'Galacean'           │       51       │  'yiiqii(154.86),GuoLei1990(133.01),cptbtptpbcptdtptp(131.16)'  │\n",
      "│   27    │        'agentUniverse'         │       41       │       'LandJerry(20.05),AniviaTn(11.40),EdwinInAu(10.79)'       │\n",
      "│   28    │         'Traas Stack'          │       34       │        'masaimu(37.63),jsy1001de(29.38),zwk1091(13.03)'         │\n",
      "│   29    │        'Apache HoraeDB'        │       34       │      'jiacai2050(45.54),chunshao90(12.54),Rachelint(9.08)'      │\n",
      "│   30    │          'Peter Cat'           │       29       │       'xingwanying(11.99),RaoHai(4.64),ch-liuzhide(4.51)'       │\n",
      "│   31    │            'DvaJS'             │       20       │        'jasonzhuang(0.51),sorrycc(0.49),remloyal(0.44)'         │\n",
      "│   32    │          'Ant Chain'           │       20       │        'zouxyan(18.24),dawn-to-dusk(4.98),i-zhen(4.17)'         │\n",
      "│   33    │             'VSAG'             │       16       │            'LHT129(11.28),wxyucs(6.69),inabao(5.38)'            │\n",
      "│   34    │         'HyperEnclave'         │       9        │       'Bonjourz(5.12),Ariel08081214(2.80),bronzeMe(2.06)'       │\n",
      "│   35    │           'SQLFlow'            │       7        │     'lucastheisen(0.39),weiguoz(0.35),terrytangyuan(0.35)'      │\n",
      "│   36    │           'CeresDB'            │       6        │        'jiacai2050(5.48),zealchen(2.03),Rachelint(0.54)'        │\n",
      "│   37    │       'Ant Mini Program'       │       6        │           'Otto-J(0.56),HammCn(0.39),bytemain(0.33)'            │\n",
      "│   38    │            'Macaca'            │       5        │         'yihuineng(3.46),xudafeng(1.93),echizen(0.74)'          │\n",
      "│   39    │            'Couler'            │       4        │      'terrytangyuan(0.88),jamindy(0.66),ignite-abd(0.42)'       │\n",
      "└─────────┴────────────────────────────────┴────────────────┴─────────────────────────────────────────────────────────────────┘\n"
     ]
    }
   ],
   "source": [
    "var getProjectOpenRankContributors = async () => {\n",
    "    console.log('Start to get contributors by OpenRank of antgroup for every project');\n",
    "    const contributorsData = await openDigger.index.openrank.getRepoCommunityOpenrank({\n",
    "        ...defaultOption,\n",
    "        labelUnion: [':companies/antgroup'],\n",
    "        groupBy: 'Project',\n",
    "        options: { limit: -1, withBot: false },\n",
    "    });\n",
    "    console.table(contributorsData.filter(row => row.name != 'Others').map(row => ({\n",
    "        name: row.name,\n",
    "        // 开发者总数\n",
    "        developerCount: row.openrank[0].length,\n",
    "        // 开发者采样\n",
    "        developers: row.openrank[0].slice(0, 3).map(d => `${d[2]}(${d[3].toFixed(2)})`).join(','),\n",
    "    })).sort((a, b) => b.developerCount - a.developerCount));\n",
    "};\n",
    "getProjectOpenRankContributors();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5ff11c83-6c46-44a8-8a47-8f34f99b61c5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "JavaScript (Node.js)",
   "language": "javascript",
   "name": "javascript"
  },
  "language_info": {
   "file_extension": ".js",
   "mimetype": "application/javascript",
   "name": "javascript",
   "version": "16.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
